<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <script>
    var arr = ["阿里巴巴", "百度", "腾讯", "京东", "网易", "字节跳动", "360", "拼多多"];


    // es5 for(var i=0;i<10;i++){}  while{}    do while() for in 
    var arr2 = []
    //1 es6  forEach(function (item) {   })
    arr.forEach(item => {
      arr2.push(item + "公司")

    })
    console.log(arr2)
    // console.log(company)
    // 2 map循环数组 返回循环处理后的数组
    var jituanarr = arr.map((item, index) => {
      if (index % 2 == 0) {
        return item + "集团"
      } else {
        return
      }
    })
    console.log(jituanarr)
    //3.filter()过滤  返回符合条件的数组项
    var farr = arr.filter((item, index) => {
      if (index % 2 == 0) {
        return item
      }
    })

    console.log(farr)

    // for of 遍历
    var obj = {
      0: "小李",
      1: 18,
      2: "男",
      length: 3
    }
    // for (var x in obj) {
    //   // x代表key
    //   console.log(obj[x])
    // }
    var arr1 = ["你好", "世界", "奥利给"]
    for (let k of arr1) {
      // for of 循环数组 k代表数组项
      console.log(k)
    }
    for (var x in arr1) {
      // x代表下标
      console.log(x)
    }
    // 把对象转为数组循环
    for (let k of Array.from(obj)) {
      console.log(k)
    }
    // 
    for (let [key, value] of Object.entries(obj)) {
      console.log(key, value)
    }
    var myobj = {
      aihao: "足球",
      shengao: 188,
      tizhong: 188
    }

    for (let [key, value] of Object.entries(myobj)) {
      console.log(key, value)
    }
  </script>
</body>

</html>